package com.example.auth.config.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.springframework.security.core.context.SecurityContext;

import java.io.IOException;

public class SecurityContextSerializer extends StdSerializer<SecurityContext> {

    public SecurityContextSerializer() {
        super(SecurityContext.class);
    }

    @Override
    public void serialize(SecurityContext value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeStartObject();
        gen.writeObjectField("authentication", value.getAuthentication());
        gen.writeEndObject();
    }
} 